package com.unitech.order.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 饮品状态信息
 */
@AllArgsConstructor
@Getter
public enum OrderStatusType {

    ERROR(-1, "错误状态"),
    INIT(0, "未支付"),
    TEST(1, "测试消息队列"),
    PAID(2, "已支付"),
    BREWING(3, "制作中"),
    BREWED(4, "制作完成"),
    TAKEN(5, "已收货"),
    CANCELLED(6, "已取消");

    // 对应t_order数据库中的status
    private Integer code;
    private String description;

    public static OrderStatusType convert(Integer code) {
        return Stream.of(values())
                .filter(e -> e.code.compareTo(code) == 0)
                .findFirst()
                .orElse(ERROR);
    }
}
